The Scandir () function returns an array that contains the files and directories in the specified path. As shown below:
Example:
Copy the Code code as follows:
Print_r (Scandir (' test_directory '));?>Output:
Copy the Code code as follows:
L Linux under Vim/usr/local/php/etc/php.inL Direct Slash Find/disable_functions enterL PRESS the I keyL Remove ScandirL Press ESC, enter wq! Save Carriage return q! Yes No save exit Lnmp Reestart Restart==========================Install thinkphp
The Scandir () function returns an array that contains the files and directories in the specified path. As shown below:
Example:
Copy Code code as follows:
Print_r (Scandir (' test_directory '));
?>
Output:
Copy Code
I am developing a project using PHP, and there is a need to use Scandir to list all the documents in the specified path.
When the document name is all numeric or English, the returned array is expected, and when the document name contains Chinese,
PHP Tutorial Scandir traversal display all files and folders under the file, the method is very simple we only use the Is_dir to determine the recursive lookup once, so you can traverse the directory all the files.
Directory traversal
Scandir () returns an array of files and directories in the specified directory.
returns an array of files and directories if successful. The failure returns FALSE.
If directory is not a directory, the e_warning level error is thrown.
Manage the newly written graph beds todayProgramThe encoding was changed to the UTF-8 format. I wanted to move closer to foreign standards. The result was just a big problem. Originally, my files were all ANSI. I used notepad to replace them with
If the Opendir (Path,context) succeeds, the function returns a directory stream, otherwise it returns false and an error. You can hide the output of an error by adding "@" in front of the function name.
The Readdir () function returns an entry in a
Analysis of the technical points:
Package files into zip formatThe ability to download filesKey analysis:
Here I'm using PHP's own ziparchive class.A We just need to new a Ziparchive object, then use the open method to create a zip file, and then
Summary:Four headers () are required for downloading files using PHP. For more information, see my another blog post: How PHP implements the download function? detailed Process AnalysisWhen calculating the file size, you do not need to open the file
Summarize:
The operation of using PHP to download files requires four headers () to refer to my other blog post: How PHP implements the download function hyper-Detailed process analysis
When calculating the size of a file, you do not need to open
The function we want to use is Scandir, which is to list the files and directories in the specified path, just like Dir.
> A more powerful Glob () function that returns a file name or directory that matches the specified pattern in the form of an
learn PHP Object-oriented -3 carefully
Preface
Ready to write a serious study of the PHP object-oriented series, using PHP to do the Web page, do not have a deep understanding of PHP, may be Sanbang enough, do not need to have much advanced. If
This article describes the PHP file and directory operations. Share to everyone for your reference, specific as follows:
File directory-related functions
Files in the output
The function we want to use has scandir, which is to list the files and directories in the specified path, just like Dir.
> A more powerful Glob () function that returns the file name or directory that matches the specified pattern in the form of an
1, to perform the requested operation, WordPress needs to access your Web server permissions. Please enter your FTP login xxxx perfect solutionBecause the permissions of the newly uploaded plugins in WordPress are WWW users, not root or other users,
This article describes how Python implements a bulk replacement of file extensions in a specified directory. Share to everyone for your reference, specific as follows:
#encoding =utf-8 #author: Walker #date: 2013-12-06 #function: Depth
PHP gets all files (including subdirectories) in the specified directory
Test environment under Linux, if you want to be in Windows, correct the way that directory paths are found in $new_dir
php function Get_file_list ($dir) {$file _list=Array (
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.